# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

# by OceanMaster in Project2
# Added homedepot_user, testPart1, testPart2, testPart3, threadtest

all: halt matmult sort testfiles homedepot_user testPart1 testPart1_p2 testPart2 testPart2_1 testPart2_2 testPart2_3 testPart2_4 testPart3 threadtest RPCTest1 RPCTest2_c1 RPCTest2_c2 RPCTest3_c1 RPCTest3_c2 RPCTest4_c1 RPCTest4_c2 MVTest1 MVTest2_c1 MVTest2_c2 bustest p3_test_1 p3_test_2 matmult_simple p3_test_1_simple p3_test_2_simple testInput manager customer clerk stockboy cashRegister customer_controller clerk_controller stockboy_controller cashRegister_controller manager_controller

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult

testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles

homedepot_user.o: homedepot_user.c
	$(CC) $(CFLAGS) -c homedepot_user.c
homedepot_user: homedepot_user.o start.o
	$(LD) $(LDFLAGS) start.o homedepot_user.o -o homedepot_user.coff
	../bin/coff2noff homedepot_user.coff homedepot_user

testPart1.o: testPart1.c
	$(CC) $(CFLAGS) -c testPart1.c
testPart1: testPart1.o start.o
	$(LD) $(LDFLAGS) start.o testPart1.o -o testPart1.coff
	../bin/coff2noff testPart1.coff testPart1

testPart1_p2.o: testPart1_p2.c
	$(CC) $(CFLAGS) -c testPart1_p2.c
testPart1_p2: testPart1_p2.o start.o
	$(LD) $(LDFLAGS) start.o testPart1_p2.o -o testPart1_p2.coff
	../bin/coff2noff testPart1_p2.coff testPart1_p2

testPart2.o: testPart2.c
	$(CC) $(CFLAGS) -c testPart2.c
testPart2: testPart2.o start.o
	$(LD) $(LDFLAGS) start.o testPart2.o -o testPart2.coff
	../bin/coff2noff testPart2.coff testPart2

testPart2_1.o: testPart2_1.c
	$(CC) $(CFLAGS) -c testPart2_1.c
testPart2_1: testPart2_1.o start.o
	$(LD) $(LDFLAGS) start.o testPart2_1.o -o testPart2_1.coff
	../bin/coff2noff testPart2_1.coff testPart2_1

testPart2_2.o: testPart2_2.c
	$(CC) $(CFLAGS) -c testPart2_2.c
testPart2_2: testPart2_2.o start.o
	$(LD) $(LDFLAGS) start.o testPart2_2.o -o testPart2_2.coff
	../bin/coff2noff testPart2_2.coff testPart2_2

testPart2_3.o: testPart2_3.c
	$(CC) $(CFLAGS) -c testPart2_3.c
testPart2_3: testPart2_3.o start.o
	$(LD) $(LDFLAGS) start.o testPart2_3.o -o testPart2_3.coff
	../bin/coff2noff testPart2_3.coff testPart2_3

testPart2_4.o: testPart2_4.c
	$(CC) $(CFLAGS) -c testPart2_4.c
testPart2_4: testPart2_4.o start.o
	$(LD) $(LDFLAGS) start.o testPart2_4.o -o testPart2_4.coff
	../bin/coff2noff testPart2_4.coff testPart2_4

testPart3.o: testPart3.c
	$(CC) $(CFLAGS) -c testPart3.c
testPart3: testPart3.o start.o
	$(LD) $(LDFLAGS) start.o testPart3.o -o testPart3.coff
	../bin/coff2noff testPart3.coff testPart3

threadtest.o: threadtest.c
	$(CC) $(CFLAGS) -c threadtest.c
threadtest: threadtest.o start.o
	$(LD) $(LDFLAGS) start.o threadtest.o -o threadtest.coff
	../bin/coff2noff threadtest.coff threadtest

RPCTest1.o: RPCTest1.c
	$(CC) $(CFLAGS) -c RPCTest1.c
RPCTest1: RPCTest1.o start.o
	$(LD) $(LDFLAGS) start.o RPCTest1.o -o RPCTest1.coff
	../bin/coff2noff RPCTest1.coff RPCTest1
bustest.o: bustest.c
	$(CC) $(CFLAGS) -c bustest.c
bustest: bustest.o start.o
	$(LD) $(LDFLAGS) start.o bustest.o -o bustest.coff
	../bin/coff2noff bustest.coff bustest
	
RPCTest2_c1.o: RPCTest2_c1.c
	$(CC) $(CFLAGS) -c RPCTest2_c1.c
RPCTest2_c1: RPCTest2_c1.o start.o
	$(LD) $(LDFLAGS) start.o RPCTest2_c1.o -o RPCTest2_c1.coff
	../bin/coff2noff RPCTest2_c1.coff RPCTest2_c1

RPCTest2_c2.o: RPCTest2_c2.c
	$(CC) $(CFLAGS) -c RPCTest2_c2.c
RPCTest2_c2: RPCTest2_c2.o start.o
	$(LD) $(LDFLAGS) start.o RPCTest2_c2.o -o RPCTest2_c2.coff
	../bin/coff2noff RPCTest2_c2.coff RPCTest2_c2


RPCTest3_c1.o: RPCTest3_c1.c
	$(CC) $(CFLAGS) -c RPCTest3_c1.c
RPCTest3_c1: RPCTest3_c1.o start.o
	$(LD) $(LDFLAGS) start.o RPCTest3_c1.o -o RPCTest3_c1.coff
	../bin/coff2noff RPCTest3_c1.coff RPCTest3_c1

RPCTest3_c2.o: RPCTest3_c2.c
	$(CC) $(CFLAGS) -c RPCTest3_c2.c
RPCTest3_c2: RPCTest3_c2.o start.o
	$(LD) $(LDFLAGS) start.o RPCTest3_c2.o -o RPCTest3_c2.coff
	../bin/coff2noff RPCTest3_c2.coff RPCTest3_c2

RPCTest4_c1.o: RPCTest4_c1.c
	$(CC) $(CFLAGS) -c RPCTest4_c1.c
RPCTest4_c1: RPCTest4_c1.o start.o
	$(LD) $(LDFLAGS) start.o RPCTest4_c1.o -o RPCTest4_c1.coff
	../bin/coff2noff RPCTest4_c1.coff RPCTest4_c1

RPCTest4_c2.o: RPCTest4_c2.c
	$(CC) $(CFLAGS) -c RPCTest4_c2.c
RPCTest4_c2: RPCTest4_c2.o start.o
	$(LD) $(LDFLAGS) start.o RPCTest4_c2.o -o RPCTest4_c2.coff
	../bin/coff2noff RPCTest4_c2.coff RPCTest4_c2

MVTest1.o: MVTest1.c
	$(CC) $(CFLAGS) -c MVTest1.c
MVTest1: MVTest1.o start.o
	$(LD) $(LDFLAGS) start.o MVTest1.o -o MVTest1.coff
	../bin/coff2noff MVTest1.coff MVTest1

MVTest2_c1.o: MVTest2_c1.c
	$(CC) $(CFLAGS) -c MVTest2_c1.c
MVTest2_c1: MVTest2_c1.o start.o
	$(LD) $(LDFLAGS) start.o MVTest2_c1.o -o MVTest2_c1.coff
	../bin/coff2noff MVTest2_c1.coff MVTest2_c1

MVTest2_c2.o: MVTest2_c2.c
	$(CC) $(CFLAGS) -c MVTest2_c2.c
MVTest2_c2: MVTest2_c2.o start.o
	$(LD) $(LDFLAGS) start.o MVTest2_c2.o -o MVTest2_c2.coff
	../bin/coff2noff MVTest2_c2.coff MVTest2_c2

p3_test_1.o: p3_test_1.c
	$(CC) $(CFLAGS) -c p3_test_1.c
p3_test_1: p3_test_1.o start.o
	$(LD) $(LDFLAGS) start.o p3_test_1.o -o p3_test_1.coff
	../bin/coff2noff p3_test_1.coff p3_test_1

p3_test_2.o: p3_test_2.c
	$(CC) $(CFLAGS) -c p3_test_2.c
p3_test_2: p3_test_2.o start.o
	$(LD) $(LDFLAGS) start.o p3_test_2.o -o p3_test_2.coff
	../bin/coff2noff p3_test_2.coff p3_test_2

matmult_simple.o: matmult_simple.c
	$(CC) $(CFLAGS) -c matmult_simple.c
matmult_simple: matmult_simple.o start.o
	$(LD) $(LDFLAGS) start.o matmult_simple.o -o matmult_simple.coff
	../bin/coff2noff matmult_simple.coff matmult_simple

p3_test_1_simple.o: p3_test_1_simple.c
	$(CC) $(CFLAGS) -c p3_test_1_simple.c
p3_test_1_simple: p3_test_1_simple.o start.o
	$(LD) $(LDFLAGS) start.o p3_test_1_simple.o -o p3_test_1_simple.coff
	../bin/coff2noff p3_test_1_simple.coff p3_test_1_simple

p3_test_2_simple.o: p3_test_2_simple.c
	$(CC) $(CFLAGS) -c p3_test_2_simple.c
p3_test_2_simple: p3_test_2_simple.o start.o
	$(LD) $(LDFLAGS) start.o p3_test_2_simple.o -o p3_test_2_simple.coff
	../bin/coff2noff p3_test_2_simple.coff p3_test_2_simple

testInput.o: testInput.c
	$(CC) $(CFLAGS) -c testInput.c
testInput: testInput.o start.o
	$(LD) $(LDFLAGS) start.o testInput.o -o testInput.coff
	../bin/coff2noff testInput.coff testInput

manager.o: manager.c
	$(CC) $(CFLAGS) -c manager.c
manager: manager.o start.o
	$(LD) $(LDFLAGS) start.o manager.o -o manager.coff
	../bin/coff2noff manager.coff manager

clerk.o: clerk.c
	$(CC) $(CFLAGS) -c clerk.c
clerk: clerk.o start.o
	$(LD) $(LDFLAGS) start.o clerk.o -o clerk.coff
	../bin/coff2noff clerk.coff clerk

customer.o: customer.c
	$(CC) $(CFLAGS) -c customer.c
customer: customer.o start.o
	$(LD) $(LDFLAGS) start.o customer.o -o customer.coff
	../bin/coff2noff customer.coff customer

stockboy.o: stockboy.c
	$(CC) $(CFLAGS) -c stockboy.c
stockboy: stockboy.o start.o
	$(LD) $(LDFLAGS) start.o stockboy.o -o stockboy.coff
	../bin/coff2noff stockboy.coff stockboy

cashRegister.o: cashRegister.c
	$(CC) $(CFLAGS) -c cashRegister.c
cashRegister: cashRegister.o start.o
	$(LD) $(LDFLAGS) start.o cashRegister.o -o cashRegister.coff
	../bin/coff2noff cashRegister.coff cashRegister

clerk_controller.o: clerk_controller.c
	$(CC) $(CFLAGS) -c clerk_controller.c
clerk_controller: clerk_controller.o start.o
	$(LD) $(LDFLAGS) start.o clerk_controller.o -o clerk_controller.coff
	../bin/coff2noff clerk_controller.coff clerk_controller

customer_controller.o: customer_controller.c
	$(CC) $(CFLAGS) -c customer_controller.c
customer_controller: customer_controller.o start.o
	$(LD) $(LDFLAGS) start.o customer_controller.o -o customer_controller.coff
	../bin/coff2noff customer_controller.coff customer_controller

stockboy_controller.o: stockboy_controller.c
	$(CC) $(CFLAGS) -c stockboy_controller.c
stockboy_controller: stockboy_controller.o start.o
	$(LD) $(LDFLAGS) start.o stockboy_controller.o -o stockboy_controller.coff
	../bin/coff2noff stockboy_controller.coff stockboy_controller

cashRegister_controller.o: cashRegister_controller.c
	$(CC) $(CFLAGS) -c cashRegister_controller.c
cashRegister_controller: cashRegister_controller.o start.o
	$(LD) $(LDFLAGS) start.o cashRegister_controller.o -o cashRegister_controller.coff
	../bin/coff2noff cashRegister_controller.coff cashRegister_controller

manager_controller.o: manager_controller.c
	$(CC) $(CFLAGS) -c manager_controller.c
manager_controller: manager_controller.o start.o
	$(LD) $(LDFLAGS) start.o manager_controller.o -o manager_controller.coff
	../bin/coff2noff manager_controller.coff manager_controller


clean:
	rm -f *.o *.coff
